package pers.cmc.mysql.model;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import pers.cmc.mysql.core.LifeCycle;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author EDY
 */
@Data
@ToString
@EqualsAndHashCode
public class Select {
    /** 生成的sql语句 */
    private String sql;
    /** 需要进行查询的表 */
    private List<String> table;
    /** 参数列表 */
    private List<Object> param;
    /** 执行的类型的类型 增删改查 */
    private String type;
    /** 链式操作的参数 */
    private List<Map<String,String>> structure;
    /** 字段的返回 */
    private String[] field;
    /**  */
    private String[] join;
    /** 生命周期 */
    private LifeCycle lifeCycle;

    public Select() {}
    public Select(String sql, List<String> table, List<Object> param, String type) {
        this.sql = sql;
        this.table = table;
        this.param = param;
        this.type = type;
    }

    public void addTable(String table){
        this.table.add(table);
    }

    public void addParam(Object table){
        this.param.add(table);
    }

    public void addField(Object table){
        this.param.add(table);
    }
    public void addJoin(Object table){
        this.param.add(table);
    }

    public void putStructure(String name,String v){
        Map<String,String> map = new HashMap<>();
        map.put(name,v);
        this.structure.add(map);
    }
}
